
/*!
 * \file     square.cpp
 * \brief    Square implementation.
 * \author   Duriez Franck
 * \author   Carton Paul-Henri
 * \version  0.1
 */

#include "constant.h"
#include "assert_macros.h"
#include "square.h"

Square::Square(QSFMLWidget *displayWidget, float *dt) : /*{{{*/
	    Drawable(displayWidget, displayWidget, dt),
	    m_container((SquareContainer*) NULL),
	    m_position_in_container(Vector2i(0,0)),
	    destroy(&Square::destroyStartingProcess, &Square::destroyProcess,
	            &Square::destroyDefaultStoppingProcess, this)
{
} /*}}}*/

Square::~Square() /*{{{*/
{
	emit isDead(m_position_in_container);
} /*}}}*/

/************
 * DRAWABLE *
 ************/
/*{{{*/
void Square::update() /*{{{*/
{
	destroy.update();
} /*}}}*/

std::string Square::toString() const /*{{{*/
{
	std::ostringstream res;
	res << "position              : (" << getPosition().x << ","
	        << getPosition().y << ")" << std::endl;
	res << "center                : (" << getCenter().x << ","
	        << getCenter().y << ")" << std::endl;
	res << "angle                 : " << getRotation() << std::endl;
	res << "position in container : (" << getPositionInContainer().x << ","
	        << getPositionInContainer().y << ")" << std::endl;
	return res.str();
} /*}}}*/
/*}}}*/

/*************
 * CONTAINER *
 *************/
/*{{{*/
SquareContainer* Square::getContainer() /*{{{*/
{
	return m_container;
} /*}}}*/

void Square::setContainer(SquareContainer *container) /*{{{*/
{
	m_container = container;
} /*}}}*/

void Square::setPositionInContainer(Vector2i coord) /*{{{*/
{
	m_position_in_container = coord;
} /*}}}*/

Vector2i Square::getPositionInContainer() const /*{{{*/
{
	return m_position_in_container;
} /*}}}*/
/*}}}*/

/****************
 *   ACTIONS    *
 ****************/
/*{{{*/
// destroy

void Square::destroyDefaultStoppingProcess() /*{{{*/
{
	destroyStoppingProcess();
	delete this;
} /*}}}*/
/*}}}*/

